// 此文件用于定义首页的接口api类型规范
// 导入requset请求
import request from '@/utils/request'


// currentCategory里面的bannerList里面的 extra
export interface extraModel {
    materialContentFrom: number
    materialName: string
    rcmdSort: true
    taskType: number
    itemFrom: number
    crmUserGroupName: number
    resourcesId: number
    materialType: string
    crmUserGroupId: number
    materialId: number
    taskId: number
  }
  
  // currentCategory里面的bannerList
  export interface bannerListModel {
    id: number
    picUrl: string
    targetUrl: string
    extra: extraModel
  }
  
  // data里面的categoryGroupList
  export interface categoryGroupListModel {
    id: number
    name: string
    categoryList: categoryListModel[]
  }
  
  // data里面的currentCategory
  export interface currentCategoryModel {
    id: number
    superCategoryId: number
    showIndex: number
    name: string
    frontName: string
    frontDesc: string
    bannerList: bannerListModel[]
    bannerUrl: string
    subCateList: []
    iconUrl: string
    imgUrl: string
    level: string
    wapBannerUrl: string
    type: number
    categoryType: number
    extra: {}
  }
  
  export interface categoryListModel {
    id: number
    superCategoryId: number
    showIndex: number
    name: string
    frontName: string
    frontNameIcon: null
    frontDesc: string
    bannerUrl: string
    bannerList: null
    iconUrl: string
    imgUrl: string
    level: string
    subCateList: []
    wapBannerUrl: string
    type: number
    categoryType: number
    extra?: {}
  }
  // data数据
  export interface categoryList {
    categoryL1List: categoryListModel[]
    categoryL2List: categoryListModel[]
    currentCategory: currentCategoryModel
    categoryGroupList: categoryGroupListModel[]
  }
  // 总数据
  export interface category {
    YXJSONArray: object
    YXJSONObject: object
    data: categoryList
    global: object
  }

/**
 * @desc 获取分类数据
 * @returns promise
 */
export const getClassify = ()=>{
    return request.get<any, category>('/item/cateList.json?__timestamp=1630131286110&categoryId=')
}

/**
 * @desc 根据分类id获取数据
 * @param id 分类id
 * @returns promise
 */
export const getClassifyList =(id:number)=>{
    return request.get<any, category>(`item/cateList.json?__timestamp=1630131455012&categoryId=${id}`)
}

/**
 * @desc 获取商品列表
 * @param subCategoryId  导航栏id
 * @param categoryId  右下商品id
 * @returns 
 */
export const getClassificationList = (subCategoryId:number,categoryId:number)=>{
    return request.get(`/item/list.json?__timestamp=1630133942864&categoryType=0&subCategoryId=${1008009}&categoryId=${1005000}`)
}